package service.impl;

import entity.Reader;
import repository.AdminRepository;
import repository.ReaderRepository;
import repository.impl.AdminRepositoryImpl;
import repository.impl.ReaderRepositoryImpl;
import service.LoginService;

import java.sql.SQLException;



public class LoginServiceImpl implements LoginService {

    private ReaderRepository readerRepository = new ReaderRepositoryImpl();
    private AdminRepository adminRepository = new AdminRepositoryImpl();


    @Override
    public int login(String username, String password) throws SQLException, ClassNotFoundException {
            // TODO Auto-generated method stub
            int k = 0;
            if(username == "" || username == null || password == ""|| password == null) {
                return k;
            }
            Reader user = readerRepository.login(username,password);

            if(!password.equals(user.getPassword())) {
                k = 0;
            }else {
                k = 1;
            }
            return k;

    }
}
